#ifndef PORTSIP_PORTSIPLIB_hxx
#define PORTSIP_PORTSIPLIB_hxx

#include "AbstractCallbackDispatcher.hxx"
#include "PortSIPTypes.hxx"

namespace PortSIP
{

#ifdef __cplusplus
extern "C" {
#endif

void PortSIP_delCallbackParameters(void * parameters);

void * PortSIP_initialize(AbstractCallbackDispatcher * callbackDispatcher,
					   TRANSPORT_TYPE transport,
					   PORTSIP_LOG_LEVEL logLevel,
					   const char * logFilePath,
					   int maxCallLines,
					   const char * sipAgent,
					   bool useVirtualAudioDevice,
					   bool useVirtualVideoDevice,
					   int * errorCode);

void PortSIP_unInitialize(void * libSDK);
int PortSIP_setLicenseKey(void * libSDK, const char * key);
int PortSIP_getNICNums(void * libSDK);
int PortSIP_getLocalIpAddress(void * libSDK, int index, char * ip, int ipSize);
int PortSIP_setUser(void * libSDK, 
					const char * userName,
					const char * displayName,
					const char * authName,
					const char * password,
					const char * localIp,
					int localSipPort,
					const char *  userDomain,
					const char *  sipServer,
					int sipServerPort,
					const char * stunServer, 
					int stunServerPort,
					const char *  outboundServer,
					int outboundServerPort);

int PortSIP_setDisplayName(void * libSDK, const char * displayName);
int PortSIP_registerServer(void * libSDK, int regExpires, int retryTimes);
int PortSIP_unRegisterServer(void * libSDK);

int PortSIP_getVersion(void * libSDK, int * majorVersion, int * minorVersion);
int PortSIP_enableReliableProvisional(void * libSDK, bool enable);
int PortSIP_enable3GppTags(void * libSDK, bool enable);
void PortSIP_enableCallbackSendingSignaling(void * libSDK, bool enable);
int PortSIP_setRtpCallback(void * libSDK, void * obj, fnReceivedRTPPacket receivedCallback, fnSendingRTPPacket sendingCallback);

int PortSIP_addAudioCodec(void * libSDK, AUDIOCODEC_TYPE codecType);
int PortSIP_addVideoCodec(void * libSDK, VIDEOCODEC_TYPE codecType);
bool PortSIP_isAudioCodecEmpty(void * libSDK);
bool PortSIP_isVideoCodecEmpty(void * libSDK);
int PortSIP_setAudioCodecPayloadType(void * libSDK, AUDIOCODEC_TYPE codecType, int payloadType);
int PortSIP_setVideoCodecPayloadType(void * libSDK, VIDEOCODEC_TYPE codecType, int payloadType);
void PortSIP_clearAudioCodec(void * libSDK);
void PortSIP_clearVideoCodec(void * libSDK);
int PortSIP_setAudioCodecParameter(void * libSDK, AUDIOCODEC_TYPE codecType, const char * parameter);
int PortSIP_setVideoCodecParameter(void * libSDK, VIDEOCODEC_TYPE codecType, const char * parameter);

int PortSIP_setSrtpPolicy(void * libSDK, SRTP_POLICY policy);
int PortSIP_setRtpPortRange(void * libSDK, int minimumRtpAudioPort, int maximumRtpAudioPort, int minimumRtpVideoPort, int maximumRtpVideoPort);
int PortSIP_setRtcpPortRange(void * libSDK, int minimumRtcpAudioPort, int maximumRtcpAudioPort, int minimumRtcpVideoPort, int maximumRtcpVideoPort);

int PortSIP_enableCallForward(void * libSDK, bool forBusyOnly, const char * forwardTo);
int PortSIP_disableCallForward(void * libSDK);
int PortSIP_enableSessionTimer(void * libSDK, int timerSeconds, SESSION_REFRESH_MODE refreshMode);
int PortSIP_disableSessionTimer(void * libSDK);
void PortSIP_setDoNotDisturb(void * libSDK, bool state);
int PortSIP_detectMwi(void * libSDK);
int PortSIP_enableCheckMwi(void * libSDK, bool state);
int PortSIP_setRtpKeepAlive(void * libSDK, bool state, int keepAlivePayloadType, int deltaTransmitTimeMS);
int PortSIP_setKeepAliveTime(void * libSDK, int keepAliveTime);

int PortSIP_getExtensionHeaderValue(void * libSDK, const char * sipMessage, const char * headerName, char * headerValue, int headerValueLength);
int PortSIP_addExtensionHeader(void * libSDK, const char * headerName, const char * headerValue);
int PortSIP_clearAddExtensionHeaders(void * libSDK);
int PortSIP_modifyHeaderValue(void * libSDK, const char * headerName, const char * headerValue);
int PortSIP_clearModifyHeaders(void * libSDK);
int PortSIP_addSupportedMimeType(void * libSDK, const char * methodName, const char * mimeType, const char * subMimeType);

int PortSIP_setAudioSamples(void * libSDK, int ptime, int maxPtime);
int PortSIP_setAudioDeviceId(void * libSDK, int inputDeviceId, int outputDeviceId);
int PortSIP_setVideoDeviceId(void * libSDK, int deviceId);
int PortSIP_setVideoResolution(void * libSDK, VIDEO_RESOLUTION resolution);
int PortSIP_setVideoBitrate(void * libSDK, int bitrateKbps);
int PortSIP_setVideoFrameRate(void * libSDK, int frameRate);
int PortSIP_sendVideo(void * libSDK, long sessionId, bool sendState);
int PortSIP_setVideoOrientation(void * libSDK, int rotation);
void PortSIP_muteMicrophone(void * libSDK, bool mute);
void PortSIP_muteSpeaker(void * libSDK, bool mute);
void PortSIP_getDynamicVolumeLevel(void * libSDK, int * speakerVolume, int * microphoneVolume);//(void * libSDK, 0-10)
void PortSIP_setLocalVideoWindow(void * libSDK, void * localVideoWindow);
int PortSIP_setRemoteVideoWindow(void * libSDK, long sessionId, void * remoteVideoWindow);
int PortSIP_displayLocalVideo(void * libSDK, bool state);
int PortSIP_setVideoNackStatus(void * libSDK, bool state);

long PortSIP_call(void * libSDK, const char * callee, bool sendSdp, bool videoCall);
int PortSIP_rejectCall(void * libSDK, long sessionId, int code);
int PortSIP_hangUp(void * libSDK, long sessionId);
int PortSIP_answerCall(void * libSDK, long sessionId, bool videoCall);
int PortSIP_updateCall(void * libSDK, long sessionId, bool enableAudio, bool enableVideo);
int PortSIP_hold(void * libSDK, long sessionId);
int PortSIP_unHold(void * libSDK, long sessionId);
int PortSIP_refer(void * libSDK, long sessionId, const char *  referTo);
int PortSIP_attendedRefer(void * libSDK, long sessionId, long replaceSessionId, const char *  referTo);
long PortSIP_acceptRefer(void * libSDK, long referId, const char * referSignaling);
int PortSIP_rejectRefer(void * libSDK, long referId);
int PortSIP_muteSession(void * libSDK,
						long sessionId,
						bool muteIncomingAudio,
						bool muteOutgoingAudio,
						bool muteIncomingVideo,
						bool muteOutgoingVideo);

int PortSIP_forwardCall(void * libSDK, long sessionId, const char * forwardTo);
int PortSIP_sendDtmf(void * libSDK, long sessionId, DTMF_METHOD dtmfMethod, int code, int dtmfDuration, bool playDtmfTone);


int PortSIP_enableSendPcmStreamToRemote(void * libSDK, long sessionId, bool state, int streamSamplesPerSec);
int PortSIP_sendPcmStreamToRemote(void * libSDK, long sessionId, const unsigned char * data, int dataLength);

int PortSIP_enableSendVideoStreamToRemote(void * libSDK, long sessionId, bool state);
int PortSIP_sendVideoStreamToRemote(void * libSDK, long sessionId, const unsigned char * data, int dataLength, int width, int height);


int PortSIP_enableAudioStreamCallback(void * libSDK, int sessionId, bool enable, AUDIOSTREAM_CALLBACK_MODE callbackMode, void * obj, fnAudioRawCallback callbackFunc);
int PortSIP_enableVideoStreamCallback(void * libSDK, int sessionId, VIDEOSTREAM_CALLBACK_MODE callbackMode, void * obj, fnVideoRawCallback callbackFunc);

int PortSIP_startRecord(void * libSDK, 
						long sessionId,
						const char * recordFilePath,
						const char * recordFileName,
						bool appendTimeStamp,
						AUDIO_FILE_FORMAT audioFileFormat,
						RECORD_MODE audioRecordMode,
						VIDEOCODEC_TYPE videoFileCodecType,
						RECORD_MODE videoRecordMode);

int PortSIP_stopRecord(void * libSDK, long sessionId);

int  PortSIP_playVideoFileToRemote(void * libSDK,
								long sessionId,
								const char * aviFile,
								bool loop,
								bool playAudio);

int PortSIP_stopPlayVideoFileToRemote(void * libSDK, long sessionId);

int PortSIP_playAudioFileToRemote(void * libSDK,
									long sessionId,
									const char * filename, // Support .wav, .amr and .pcm file formats
									int fileSamplesPerSec, // Must set fileSamplesPerSec for play .pcm file 
									bool loop);

int PortSIP_stopPlayAudioFileToRemote(void * libSDK, long sessionId);

int PortSIP_playAudioFileToRemoteAsBackground(void * libSDK, long sessionId, const char * filename, int fileSamplesPerSec);
int PortSIP_stopPlayAudioFileToRemoteAsBackground(void * libSDK, long sessionId);

int PortSIP_createConference(void * libSDK, void * conferenceVideoWindow, VIDEO_RESOLUTION videoResolution, bool displayLocalVideoInConference);
void PortSIP_destroyConference(void * libSDK);
int PortSIP_setConferenceVideoWindow(void * libSDK, void * conferenceVideoWindow);
int PortSIP_joinToConference(void * libSDK, long sessionId);
int PortSIP_removeFromConference(void * libSDK, long sessionId);	

int PortSIP_setAudioRtcpBandwidth(void * libSDK, long sessionId, int BitsRR, int BitsRS, int KBitsAS);
int PortSIP_setVideoRtcpBandwidth(void * libSDK, long sessionId, int BitsRR, int BitsRS, int KBitsAS);
int PortSIP_getNetworkStatistics(void * libSDK, long sessionId,
								 int * currentBufferSize,
								 int * preferredBufferSize,
								 int * currentPacketLossRate,
								 int * currentDiscardRate,
								 int * currentExpandRate,
								 int * currentPreemptiveRate,
								 int * currentAccelerateRate);

int PortSIP_getAudioRtpStatistics(void * libSDK, long sessionId, 
								int * averageJitterMs,
								int * maxJitterMs,
								int * discardedPackets);


int PortSIP_getAudioRtcpStatistics(void * libSDK, long sessionId,
								int * bytesSent,
								int * packetsSent,
								int * bytesReceived,
								int * packetsReceived);

int PortSIP_getVideoRtpStatistics(void * libSDK, long sessionId, 
								int * bytesSent,
								int * packetsSent,
								int * bytesReceived,
								int * packetsReceived);

void PortSIP_enableVAD(void * libSDK, bool state);
void PortSIP_enableAEC(void * libSDK, bool state);
void PortSIP_enableCNG(void * libSDK, bool state);
void PortSIP_enableAGC(void * libSDK, bool state);
void PortSIP_enableANS(void * libSDK, bool state);
int PortSIP_setAudioQos(void * libSDK, bool enable, int DSCPValue, int priority);
int PortSIP_setVideoQos(void * libSDK, bool enable, int DSCPValue);


int PortSIP_sendOptions(void * libSDK, const char * to, const char * sdp);
int PortSIP_sendInfo(void * libSDK, long sessionId, const char * mimeType, const char * subMimeType, const char * infoContents);

long PortSIP_sendMessage(void * libSDK, 
							long sessionId, 
							const char * mimeType, 
							const char * subMimeType,
							const unsigned char * message,
							int messageLength);

long PortSIP_sendOutOfDialogMessage(void * libSDK, 
									const char * to, 
									 const char * mimeType, 
									 const char * subMimeType, 
									 const unsigned char * message, 
									 int messageLength);

int PortSIP_presenceSubscribeContact(void * libSDK, const char * contact, const char * subject);
int PortSIP_presenceAcceptSubscribe(void * libSDK, long subscribeId);
int PortSIP_presenceRejectSubscribe(void * libSDK, long subscribeId);
int PortSIP_presenceOnline(void * libSDK, long subscribeId, const char * statusText);
int PortSIP_presenceOffline(void * libSDK, long subscribeId);


//////////////////////////////////////////////////////////////////////////
//
// Device Manage functions.
//
//////////////////////////////////////////////////////////////////////////

int PortSIP_getNumOfRecordingDevices(void * libSDK);

int PortSIP_getNumOfPlayoutDevices(void * libSDK);

int PortSIP_getRecordingDeviceName(void * libSDK,  
								   int index, 
								   char * nameUTF8, 
								   int nameUTF8Length);

int PortSIP_getPlayoutDeviceName(void * libSDK,  
								 int index, 
								 char * nameUTF8,
								 int nameUTF8Length);

int PortSIP_setSpeakerVolume(void * libSDK,  unsigned int volume);
int PortSIP_getSpeakerVolume(void * libSDK);

int PortSIP_setSystemOutputMute(void * libSDK,  bool enable);
bool PortSIP_getSystemOutputMute(void * libSDK);
int PortSIP_setMicVolume(void * libSDK,  unsigned int volume);
int PortSIP_getMicVolume(void * libSDK);
int PortSIP_setSystemInputMute(void * libSDK,  bool enable);
bool PortSIP_getSystemInputMute(void * libSDK);
void PortSIP_audioPlayLoopbackTest(void * libSDK, bool enable);

// Video device
int PortSIP_getNumOfVideoCaptureDevices(void * libSDK);
int PortSIP_getVideoCaptureDeviceName(void * libSDK,
										unsigned int index, 
									  char * uniqueIdUTF8,
									  const unsigned int uniqueIdUTF8Length,
									  char* deviceNameUTF8,
									  const unsigned int deviceNameUTF8Length);

int PortSIP_showVideoCaptureSettingsDialogBox(void * libSDK, 
										const char * uniqueIdUTF8,
										const unsigned int uniqueIdUTF8Length,
										const char * dialogTitle, 
										void * parentWindow,
										const unsigned int x, 
										const unsigned int y);


}

#ifdef __cplusplus
}
#endif


#endif
